﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Itasa.API;

namespace Itasa.RSS
{
    internal class Torrent_Show
    {

        internal Show Show;
        internal List<Torrent_Version> VersionList;

        internal Torrent_Show(Show s)
        {
            this.Show = s;
            this.VersionList = new List<Torrent_Version>();
        }

        internal void AddVersion(Torrent_Version tv)
        {
            List<RSS_Torrent> lrt = new List<RSS_Torrent>();
            String[] showToks = Params.cleanPathName(Show.Name.ToLower()).Split(new Char[] { ' ' });
            foreach (RSS_Torrent rt in tv.TorrentList)
            {
                bool add = true;
                foreach (String s in showToks)
                {
                    if (!rt.Name.ToLower().Contains(s)) add = false;
                }
                if (add) lrt.Add(rt);
            }
            tv.TorrentList = lrt;
            if (tv.TorrentList.Count > 0) this.VersionList.Add(tv);
        }

    }
}
